﻿namespace MSRI.DesktopAgent.CeRapi
{
    using System;
    using System.Runtime.InteropServices;

    public class UnmanagedAPI
    {
        public const uint HKEY_CLASSES_ROOT = 0x80000000;
        public const uint HKEY_CURRENT_USER = 0x80000001;
        public const uint HKEY_LOCAL_MACHINE = 0x80000002;
        public const uint HKEY_USERS = 0x80000003;

        [DllImport("rapi.dll")]
        public static extern int CeCloseHandle(int hObject);
        [DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
        internal static extern int CeCreateProcess(string pszImageName, string pszCmdLine, IntPtr psaProcess, IntPtr psaThread, int fInheritHandles, int fdwCreate, IntPtr pvEnvironment, IntPtr pszCurDir, IntPtr psiStartInfo, ref PROCESS_INFORMATION pi);
        [DllImport("rapi.dll")]
        public static extern int CeRapiInit();
        [DllImport("rapi.dll")]
        public static extern int CeRapiUninit();
        [DllImport("rapi.dll")]
        public static extern int CeRegCloseKey(uint hkey);
        [DllImport("rapi.dll", CharSet=CharSet.Unicode)]
        public static extern uint CeRegOpenKeyEx(uint HKEY, string lpSubKey, int ulOptions, uint samDesired, out uint phkResult);
        [DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
        public static extern uint CeRegQueryValueEx(uint hKey, string lpValueName, int lpReserved, ref int lpType, byte[] lpData, ref int lpchData);
    }
}

